package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CaseMemberApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.apidto.UnbindPartnerToPremisesReqDto;
import com.yixun.qfbao.apidto.UnbindPartnerToPremisesResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.UnbindPartnerToPremisesReqVo;
import com.yixun.qfbao.xf.model.CaseMember;
import com.yixun.qfbao.xf.model.dto.CaseMemberDto;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import com.yixun.qfbao.xf.service.CaseMemberService;

/**
 * 解绑经纪人驻守楼盘
 * 
 * @author JHSong
 *		
 */
@Service("unbindPartnerToPremisesHander")
public class UnbindPartnerToPremisesHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(UnbindPartnerToPremisesHander.class);

	@Autowired
	private CaseMemberApiService caseMemberApiService;
	
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		UnbindPartnerToPremisesReqVo req = (UnbindPartnerToPremisesReqVo)reqDto;
		UnbindPartnerToPremisesReqDto reqDto1 = req.getParams();
		BaseResponseDTO<UnbindPartnerToPremisesResDto> res = new BaseResponseDTO<UnbindPartnerToPremisesResDto>();
		UnbindPartnerToPremisesResDto resDto = new UnbindPartnerToPremisesResDto();
		try {
			if(null != reqDto1.getCmId()) {
				caseMemberApiService.unSetCaseHotline(reqDto1.getCmId());
				resDto.setResultMsg("取消驻守成功!");
				resDto.setResult(ResultEnum.SUCCESS.getNo());
			}
		} catch (Exception e) {
			logger.error("UnbindPartnerToPremisesHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("取消经纪人驻守楼盘失败!");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
	
}
